package org.an.proj.contacts.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * Created by Fcy on 2016/3/10.<br/>
 * 适用于 GridView中显示正方形的item
 */
public class SquareFrameLayout extends FrameLayout {

  public SquareFrameLayout(Context context) {
    super(context);
  }

  public SquareFrameLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    //        setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
    //		        getDefaultSize(0, heightMeasureSpec));
    //
    //		// Children are just made to fill our space.
    //		int childWidthSize = getMeasuredWidth();
    //		// 高度和宽度一样
    //		heightMeasureSpec = widthMeasureSpec = MeasureSpec
    //		        .makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
    //		super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, widthMeasureSpec);
  }
}
